//
//  BKResultZhiYuanViewController.m
//  baokaodaxue
//
//  Created by dangyangyang on 15/6/2.
//  Copyright (c) 2015年 宏图教育. All rights reserved.
//

#import "BKResultZhiYuanViewController.h"
#import "BKZhiYuanTableViewCell.h"


static NSString *zhiyuan = @"zhiyuan";

@interface BKResultZhiYuanViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end

@implementation BKResultZhiYuanViewController
- (IBAction)p_dismiss:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    [_tableView registerNib:[UINib nibWithNibName:NSStringFromClass([BKZhiYuanTableViewCell class]) bundle:nil] forCellReuseIdentifier:zhiyuan];
    
    _tableView.separatorColor = [UIColor clearColor];
    [_tableView reloadData];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)setData:(NSDictionary *)data{

    _data = data;
    [_tableView reloadData];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    return 5;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{

    return [UIView new];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    return 44;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{

    return 10;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    BKZhiYuanTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:zhiyuan];
    switch (indexPath.row) {
        case 0:
            
            if ([_data[@"zy1"] isKindOfClass:[NSDictionary class]]) {
                cell.name.text = _data[@"zy1"][@"name"];
                cell.hlevel.text = _data[@"zy1"][@"14h"];
                cell.alever.text = _data[@"zy1"][@"14a"];
                cell.llevel.text = _data[@"zy1"][@"14l"];
            }
           
            break;
         case 1:
            if ([_data[@"zy2"] isKindOfClass:[NSDictionary class]]) {
            
                cell.name.text = _data[@"zy2"][@"name"];
                cell.hlevel.text = _data[@"zy2"][@"14h"];
                cell.alever.text = _data[@"zy2"][@"14a"];
                cell.llevel.text = _data[@"zy2"][@"14l"];
            }
           
            break;
        case 2:
            if ([_data[@"zy3"] isKindOfClass:[NSDictionary class]]) {
                
                cell.name.text = _data[@"zy3"][@"name"];
                cell.hlevel.text = _data[@"zy3"][@"14h"];
                cell.alever.text = _data[@"zy3"][@"14a"];
                cell.llevel.text = _data[@"zy3"][@"14l"];
            }

           
            break;
        case 3:
            if ([_data[@"zy4"] isKindOfClass:[NSDictionary class]]) {
                cell.name.text = _data[@"zy4"][@"name"];
                cell.hlevel.text = _data[@"zy4"][@"14h"];
                cell.alever.text = _data[@"zy4"][@"14a"];
                cell.llevel.text = _data[@"zy4"][@"14l"];

            }
                       break;
        case 4:
            if ([_data[@"zy5"] isKindOfClass:[NSDictionary class]]) {
                cell.name.text = _data[@"zy5"][@"name"];
                cell.hlevel.text = _data[@"zy5"][@"14h"];
                cell.alever.text = _data[@"zy5"][@"14a"];
                cell.llevel.text = _data[@"zy5"][@"14l"];
                break;
            }

           
        default:
            break;
    }
    
    if (indexPath.row%2==0) {
        cell.backgroundColor = [UIColor colorWithRed:0.867 green:0.910 blue:0.925 alpha:1.000];
    }else{
     cell.backgroundColor = [UIColor clearColor];
    }
    return cell;
}
@end
